package com.ruoyi.personnel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.personnel.domain.ResearchProject;
import com.ruoyi.personnel.mapper.ResearchProjectMapper;
import com.ruoyi.personnel.service.IResearchProjectService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 科研项目Service业务层处理
 *
 * @author ruoyi
 * @date 2021-03-01
 */
@Service
public class ResearchProjectServiceImpl extends ServiceImpl<ResearchProjectMapper, ResearchProject> implements IResearchProjectService {

    @Override
    public List<ResearchProject> queryList(ResearchProject researchProject) {
        LambdaQueryWrapper<ResearchProject> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(researchProject.getName())){
            lqw.like(ResearchProject::getName ,researchProject.getName());
        }
        if (StringUtils.isNotBlank(researchProject.getJobNumber())){
            lqw.eq(ResearchProject::getJobNumber ,researchProject.getJobNumber());
        }
        if (StringUtils.isNotBlank(researchProject.getPersonnelId())){
            lqw.eq(ResearchProject::getPersonnelId ,researchProject.getPersonnelId());
        }
        if (researchProject.getOfficeId() != null){
            lqw.eq(ResearchProject::getOfficeId ,researchProject.getOfficeId());
        }
        if (StringUtils.isNotBlank(researchProject.getOfficeName())){
            lqw.like(ResearchProject::getOfficeName ,researchProject.getOfficeName());
        }
        if (StringUtils.isNotBlank(researchProject.getProjectName())){
            lqw.like(ResearchProject::getProjectName ,researchProject.getProjectName());
        }
        if (StringUtils.isNotBlank(researchProject.getProjectSource())){
            lqw.eq(ResearchProject::getProjectSource ,researchProject.getProjectSource());
        }
        if (StringUtils.isNotBlank(researchProject.getProjectLevel())){
            lqw.eq(ResearchProject::getProjectLevel ,researchProject.getProjectLevel());
        }
        if (StringUtils.isNotBlank(researchProject.getProjectNo())){
            lqw.eq(ResearchProject::getProjectNo ,researchProject.getProjectNo());
        }
        if (StringUtils.isNotBlank(researchProject.getStartTime())){
            lqw.eq(ResearchProject::getStartTime ,researchProject.getStartTime());
        }
        if (StringUtils.isNotBlank(researchProject.getPlannedTime())){
            lqw.eq(ResearchProject::getPlannedTime ,researchProject.getPlannedTime());
        }
        if (researchProject.getBidFee() != null){
            lqw.eq(ResearchProject::getBidFee ,researchProject.getBidFee());
        }
        if (StringUtils.isNotBlank(researchProject.getProjectMember())){
            lqw.eq(ResearchProject::getProjectMember ,researchProject.getProjectMember());
        }
        if (researchProject.getMatchingFee() != null){
            lqw.eq(ResearchProject::getMatchingFee ,researchProject.getMatchingFee());
        }
        if (StringUtils.isNotBlank(researchProject.getEnclosure())){
            lqw.eq(ResearchProject::getEnclosure ,researchProject.getEnclosure());
        }
        if (StringUtils.isNotBlank(researchProject.getEnclosureName())){
            lqw.like(ResearchProject::getEnclosureName ,researchProject.getEnclosureName());
        }
        if (StringUtils.isNotBlank(researchProject.getStatus())){
            lqw.eq(ResearchProject::getStatus ,researchProject.getStatus());
        }
        return this.list(lqw);
    }
}
